home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15163 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  48 lines

  1. Path: gollum.kingston.net!usenet
  2. From: girard@haventree.com (Eugene Girard)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: sscanf alternative in C++
  5. Date: Wed, 03 Apr 1996 21:14:59 GMT
  6. Organization: HavenTree Software, Limited
  7. Message-ID: <4jut92$kbo@gollum.kingston.net>
  8. References: <4jt589$fl0@mirv.unsw.edu.au>
  9. NNTP-Posting-Host: buddy.haventree.com
  10. X-Newsreader: Forte Free Agent v0.55
  11.  
  12. jeroen@fatboy.gas.unsw.edu.au (Jeroen Dijkmeijer) wrote:
  13.  
  14. >Hello,
  15.  
  16. >is there a nice way in C++ to have a function like the sscanf function in C.
  17. >e.g. specify the string and a pointer to the target, and as a result of the function, the status whether it succeeded or not.
  18.  
  19. Yes, C++ fully supports <stdarg.h>, with which you could write:
  20.  
  21. #include <stdarg.h>
  22. int MySScanF( char *buffer, const char *fmt, ...)
  23. {
  24.    va_list  argptr;
  25.    int cnt;
  26.  
  27.    va_start(argptr, fmt);
  28.    cnt = vsscanf(buffer, fmt, argptr);
  29.    va_end(argptr);
  30.  
  31.    return(cnt);
  32. }
  33.  
  34. >Thanks in advance.
  35. >regards
  36. >Jeroen.
  37.  
  38. (Or you could use the sscanf() function itself....)
  39. Gene
  40.  
  41.  
  42.  
  43. --
  44. Eugene Girard, Programmer, HavenTree Software Limited
  45. HavenTree makes EasyFlow (Windows, DOS, MAC) and Nodemap (Windows, DOS)
  46. For more information, check out http://www.haventree.com
  47.  
  48.